<form id="addOrUpdateForm" lay-filter="addOrUpdateForm" class="layui-form model-form">

    <input name="id" type="hidden"/>
    <div class="layui-form-item">
        <label class="layui-form-label layui-form-required">投诉类型</label>
        <div class="layui-input-block">
            <select name="comId" lay-verify="required" required></select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label layui-form-required">投诉内容</label>
        <div class="layui-input-block">
            <input name="remarks" class="layui-input" placeholder="请输入投诉内容" lay-verType="tips" lay-verify="required" required/>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label layui-form-required">投诉人</label>
        <div class="layui-input-block">
            <input name="ownerId" class="layui-input"  placeholder="请输入投诉人" lay-verType="tips" lay-verify="required" required/>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label layui-form-required">投诉时间</label>
        <div class="layui-input-block">
            <input type="text" name="comDate" id="comDateId" placeholder="请选择投诉时间" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item" name="look">
        <label class="layui-form-label ">处理状态</label>
        <div class="layui-input-block">
            <select name="status"></select>
        </div>
    </div>

    <div class="layui-form-item" name="look">
        <label class="layui-form-label ">处理时间</label>
        <div class="layui-input-block">
            <input type="text" name="handleDate" id="handleDateId" placeholder="请选择处理时间" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item" name="look">
        <label class="layui-form-label ">处理人</label>
        <div class="layui-input-block">
            <input name="clr" class="layui-input" placeholder="请输入处理人"  />
        </div>
    </div>

    <div class="layui-form-item text-right">
        <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
        <button class="layui-btn" lay-filter="formSubmitBtn" lay-submit>保存</button>
    </div>
</form>

<script>
    layui.use(['layer', 'form', 'admin', 'xnUtil', 'xmSelect', 'laydate'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var admin = layui.admin;
        var xnUtil = layui.xnUtil;
        var xmSelect = layui.xmSelect;
        var laydate = layui.laydate;

        xnUtil.rendDictDropDown(null, 'status', 'chuli_state', '请选择处理状态', null);
        xnUtil.rendDictDropDown(null, 'comId', 'tousu_state', '请选择投诉类型', null);
        var name = layui.data(admin.setter.tableName).loginUser.name;

        $("[name='ownerId']").val(name);

        if (name!=="管理员"){
            $("[name='look']").hide();
        }

        laydate.render({
            elem: '#comDateId'
            ,type: 'datetime'
        });
        laydate.render({
            elem: '#handleDateId'
            ,type: 'datetime'
        });

        var editData = admin.getLayerData('#addOrUpdateForm').data;
        if(editData !== null && editData !== undefined) {
            form.val('addOrUpdateForm', editData);
        }

        /**
         * 表单提交事件
         */
        form.on('submit(formSubmitBtn)', function (data) {
            layer.load(2);

            var url = editData ? getProjectUrl() + 'complaint/edit' : getProjectUrl() + 'complaint/add';
            admin.req(url, JSON.stringify(data.field), function(res){
                layer.msg(res.message, {icon: 1, time: 1000}, function () {
                    admin.putLayerData('formOk', true, '#addOrUpdateForm');
                    admin.closeDialog('#addOrUpdateForm');
                });
            }, 'post');
            return false;
        });
    });
</script>
</body>
</html>
